package cn.iocoder.yudao.module.member.dal.mysql.cardsecurity;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.cardsecurity.CardSecurityDo;
import cn.iocoder.yudao.module.member.dal.dataobject.cardsecurity.ExchangeConfigDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface ExchangeConfigMapper extends BaseMapperX<ExchangeConfigDO> {

    default ExchangeConfigDO selectByUserId(Long userId){
        return selectOne(new QueryWrapper<ExchangeConfigDO>().eq("user_id", userId));
    }

    default ExchangeConfigDO selectByprefix(String prefix, Long id){
        return selectOne(new QueryWrapper<ExchangeConfigDO>().eq("prefix", prefix).ne(!ObjectUtil.isEmpty(id), "id", id));
    }

    default ExchangeConfigDO getByPrefix(String prefix){
        return selectOne(new LambdaQueryWrapperX<ExchangeConfigDO>().eq(ExchangeConfigDO::getPrefix, prefix));
    }
}
